// 商品分类全局组件的小仓库
import { defineStore } from "pinia";
import { reqC1,reqC2 ,reqC3} from "@/api/product/attr";
import type{CategoryResponseData} from "@/api/product/attr/type";
import type { CategoryState } from "./types/type";
let useCategoryStore=defineStore('Category',{
    state:():CategoryState=>{
        return{
            c1id:'',
            c1Arr:[],
            c2id:'',
            c2Arr:[],
            c3id:'',
            c3Arr:[]  
        }
    },
    actions:{
        async getC1(){
            let result:CategoryResponseData=await reqC1();
            if(result.code==200){
                this.c1Arr=result.data 

            }
        },
        async getc2(){
           let result:CategoryResponseData= await reqC2(this.c1id);
            if(result.code==200){
                this.c2Arr=result.data;
            }
            
        },
        async getc3(){
            let result=await reqC3(this.c2id);
            if(result.code==200){
                this.c3Arr=result.data
            }
            
        }
    },
    getters:{

    }
})
export  default useCategoryStore;